﻿using AutoMapper;
using MediatR;
using SheepStorage.API.Application.Command.DepartmentCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.DepartmentHandler
{
    public class DepartmentDelCommandHandler : IRequestHandler<DepartmentDelCommand, Results<int>>
    {
        private readonly IDepartmentService departmentService;

        public DepartmentDelCommandHandler(IDepartmentService departmentService)
        {
            this.departmentService = departmentService;
        }

        /// <summary>
        /// 部门删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<int>> Handle(DepartmentDelCommand request, CancellationToken cancellationToken)
        {
            var list = departmentService.DelDepartment(request.DepartmentId);
            return Results<int>.DataResult(list);
        }
    }

}
